﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_CM_GetClientContactInfo]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_CM_GetClientContactInfo];
GO
CREATE PROCEDURE [dbo].[sproc_CM_GetClientContactInfo]
@clientid int
AS
    IF(@clientid=0)
    SELECT * FROM 
    UDS_CM_ClientContact 
    ORDER BY ID DESC
    ELSE 
    SELECT * FROM 
    UDS_CM_ClientContact 
    --LEFT OUTER JOIN UDS_CM_ClientContact_Cooperatingman ON UDS_CM_ClientContact.id=UDS_CM_ClientContact_Cooperatingman.contactid 
    --LEFT OUTER JOIN UDS_CM_ClientContact_Linkman ON UDS_CM_ClientContact.id=UDS_CM_ClientContact_Linkman.contactid
    WHERE UDS_CM_ClientContact.ClientID=@clientid
    ORDER BY ID DESC